Skip to content

feat(bin): add pr=batch registry token to ship branches through a project's batch script - #4

Merged
keyse merged 3 commits into
mainfrom
feat/pr-batch
Nov 22, 2026
Merged

keyse merged 3 commits into
mainfrom
feat/pr-batch

Conversation

@keyse

@keyse keyse commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Intent

Make firstmate ship keyse/Warka branches through Warka's own per-user batching script (scripts/batch.sh) instead of one PR per branch. Add a new value pr=batch to the existing pr= registry token in data/projects.md (beside pr=manual). It is accepted on no-mistakes, no-mistakes-prod-only and direct-PR projects, and refused on local-only (nothing to ship into) and beside any forge= token. Brief, spawn and promote carry it exactly like pr=manual (Delivery contract: mode= pr=batch; spawn refuses drift both ways), but unlike manual it also binds direct-PR tasks so internal-only work is batched too. Worker contract: a no-mistakes worker runs its local gate with --skip pr,ci (review/test/document/lint/push still run); a direct-PR worker pushes its fm/* branch and opens no PR. The worker then waits for the project's branch-check workflow (gh run watch, no bare sleep), runs scripts/batch.sh ship, and reads scripts/batch.sh status: if its branch is in the open batch it watches the batch PR's checks and reports the ordinary CI-ready line 'done: PR checks green' so firstmate's existing pr-check registration, merge poll, yolo merge and teardown all work unchanged with several tasks sharing one batch PR (teardown's landed test passes because batches merge with --no-ff); if queued it appends 'paused: queued for the next batch behind PR ' and stops (parked, not failed); if a batch check fails it appends 'blocked: batch PR failed ...; needs a fix-forward branch cut from scripts/batch.sh base' and stops. A batched branch is never rewritten; failures are fixed forward by a new crew task spawned with --base-branch set to the batch branch. Rule 1 gets a single carve-out letting scripts/batch.sh ship push batch branches, open or extend the batch PR and arm auto-merge; the worker never runs batch.sh subcommands other than status, ship and base. Firstmate itself never runs batch.sh (hard rule 1: no state-changing commands in projects), so the ship-landing skill tells firstmate to steer queued workers one at a time to resume at the ship step when a batch PR merges or closes (that ship opens the next batch), and for a failing batch to dispatch ONE fix-forward ship and then steer blocked workers to resume watching. Docs (docs/configuration.md PR posture selection, project-management skill, README) note batch.automerge should only be set on +yolo projects. Registering Warka with pr=batch is deliberately NOT part of this change: it is applied to the private registry only after this lands, because the running home would refuse the unknown token. This ships to the keyse/firstmate fork only; never to kunchenguid/firstmate upstream. Repo style: one sentence per line in Markdown, plain dash never em dash, no agent co-author.

What Changed

  • bin/fm-project-mode.sh now accepts pr=batch as a new pr= registry token. It is allowed on no-mistakes, no-mistakes-prod-only and direct-PR projects. It is refused (exit 3) on local-only projects and next to any forge= token. fm_pr_text_valid in bin/fm-dod-lib.sh applies the same rules. fm-brief.sh --pr batch, fm-spawn.sh and fm-promote.sh carry the token the same way they carry pr=manual, with Delivery contract: mode=<m> pr=batch. Unlike manual, it also binds direct-PR tasks, and spawn refuses a brief that drifts from the registry in either direction.
  • New fm_dod_batch_ship_steps worker contract in bin/fm-dod-lib.sh:
    • A no-mistakes worker runs its gate with --skip pr,ci. A direct-PR worker pushes its branch and opens no PR.
    • The worker then waits for the branch check with gh run watch and runs scripts/batch.sh ship, then reads scripts/batch.sh status. It reports done: PR <batch url> checks green when its branch is in the open batch, paused: queued for the next batch behind PR <url> when it is queued, or blocked: batch PR <url> failed ... when a batch check fails.
    • The worker never rewrites a batched branch and only runs the status, ship and base subcommands.
    • Rule 1 gets a single carve-out that lets scripts/batch.sh ship push batch branches, open or extend the batch PR, and arm auto-merge.
  • Docs and tests:
    • The ship-landing skill tells firstmate to steer queued workers one at a time when a batch PR merges or closes. For a failing batch, it dispatches one fix-forward ship with --base-branch set to the batch branch.
    • docs/configuration.md, the project-management skill and the README document pr=batch and note that batch.automerge belongs only on +yolo projects.
    • tests/fm-project-mode.test.sh and tests/fm-task-delivery.test.sh cover the token's accept/refuse rules and the brief, spawn and promote behavior.

🤖 Generated with Claude Code

Risk Assessment

⚠️ Medium: The registry, brief, spawn and promote handling of pr=batch is consistent and tested, but two required docs omit the +yolo auto-merge note and firstmate's default squash merge of a shared batch PR contradicts the intent's --no-ff assumption, so the change is safe to merge only once those are addressed or accepted.

Testing

I drove the real firstmate CLIs (fm-project-mode, fm-brief, fm-spawn, fm-promote) against disposable marked lab homes and fixture git projects, and saved transcripts plus the rendered briefs and promote payloads as evidence. Registry: pr=batch resolves on no-mistakes, no-mistakes-prod-only and direct-PR, and every invalid entry exits 3 with a reason, while --forge still answers. Briefs: both modes record "Delivery contract: mode=<m> pr=batch". The no-mistakes brief has --skip pr,ci only. Both carry the scripts/batch.sh ship exception in rule 1 and the paused, blocked and done lines. A fix-forward --base-branch brief rebases onto and merges from the batch branch. Every invalid combination is refused without writing a brief. Spawn refused drift in both directions and recorded no task. Agreeing briefs passed the pr= check and stopped later only because tmux is not installed, so worker panes were never actually launched. Promote delivered pr=batch plus the carve-out for no-mistakes and direct-PR, and plain local-only when promoted to local-only. Both targeted test files pass. The end-to-end GitHub batch flow (real batch.sh, a batch PR, the merge poll, teardown) was not driven. This change has no UI, so there are no screenshots.

  • Live validation: ✅ go - 8 of 10 scenarios driven live against the product
Scenario Result Live Evidence
Captain registers pr=batch on no-mistakes, no-mistakes-prod-only and direct-PR projects and fm-project-mode --pr reports 'batch' with the two-word posture unchanged ✅ pass live 01-project-mode-transcript.txt
Adversarial: pr=batch on local-only, beside forge=forgejo or forge=gerrit, or an unknown pr=batches value is refused (exit 3, empty stdout, reason named) while --forge still answers ✅ pass live 01-project-mode-transcript.txt
fm-brief --pr batch on no-mistakes renders 'Delivery contract: mode=no-mistakes pr=batch', --skip pr,ci only, the rule-1 scripts/batch.sh ship carve-out, and the done/paused/blocked lines ✅ pass live 02-brief-scaffold-transcript.txt, 03-brief-wk-nm.md
fm-brief --pr batch on direct-PR pushes fm/* and opens no PR, then follows the same batch steps and carve-out ✅ pass live 03-brief-wk-dpr.md
Fix-forward brief with --base-branch set to the batch branch rebases onto it and merges origin/<batch> to resolve conflicts ✅ pass live 03-brief-wk-fix.md
Adversarial: fm-brief refuses --pr batch on local-only, with --forge forgejo or gerrit, on --scout, and an unknown --pr value, writing no brief ✅ pass live 02-brief-scaffold-transcript.txt
Adversarial: fm-spawn refuses drift both ways (registry pr=batch vs brief without it on a prod-only project's direct-PR task; brief pr=batch vs registry without it), records no task, and prints the ri… ✅ pass live 04-spawn-transcript.txt
fm-spawn accepts an agreeing pr=batch brief for direct-PR and no-mistakes+yolo and launches the worker ⏸️ untested no Live, both agreeing spawns passed the pr= binding check, then failed creating the endpoint because tmux is not on PATH. The Herdr lab (bin/fm-herdr-lab.sh prepare) refused: 'fleet-state tripwire requi…
fm-promote of a scout on a pr=batch project delivers pr=batch plus the rule-1 carve-out for no-mistakes and direct-PR, and drops it for local-only ✅ pass live 05-promote-transcript.txt and 05-promote-*-payload.md
End-to-end batch flow: worker runs scripts/batch.sh ship, reports 'done: PR <batch> checks green', several tasks share one batch PR through pr-check, the merge poll and teardown ⏸️ untested no This needs a GitHub repository with Warka's scripts/batch.sh, its branch-check workflow, a gh login that can open PRs, and a running worker agent. Making a GitHub repo or PR is an outward-facing actio…
Evidence: Registry resolution/refusal transcript

Source: Registry resolution/refusal transcript

$ FM_HOME=$LAB bin/fm-project-mode.sh  warka-nm
no-mistakes on
[exit 0]
$ FM_HOME=$LAB bin/fm-project-mode.sh --pr warka-nm
batch
[exit 0]
$ FM_HOME=$LAB bin/fm-project-mode.sh --forge warka-nm
none
[exit 0]
$ FM_HOME=$LAB bin/fm-project-mode.sh  warka-prod
no-mistakes off
[exit 0]
$ FM_HOME=$LAB bin/fm-project-mode.sh --pr warka-prod
batch
[exit 0]
$ FM_HOME=$LAB bin/fm-project-mode.sh --forge warka-prod
none
[exit 0]
$ FM_HOME=$LAB bin/fm-project-mode.sh  warka-direct
direct-PR off
[exit 0]
$ FM_HOME=$LAB bin/fm-project-mode.sh --pr warka-direct
batch
[exit 0]
$ FM_HOME=$LAB bin/fm-project-mode.sh --forge warka-direct
none
[exit 0]
$ FM_HOME=$LAB bin/fm-project-mode.sh  warka-local
refused: warka-local is registered local-only with pr=batch in $LAB/data/projects.md; local-only opens no pull request, so there is no batch to ship into; register no-mistakes or direct-PR, or drop the pr token
[exit 3]
$ FM_HOME=$LAB bin/fm-project-mode.sh --pr warka-local
refused: warka-local is registered local-only with pr=batch in $LAB/data/projects.md; local-only opens no pull request, so there is no batch to ship into; register no-mistakes or direct-PR, or drop the pr token
[exit 3]
$ FM_HOME=$LAB bin/fm-project-mode.sh --forge warka-local
none
[exit 0]
$ FM_HOME=$LAB bin/fm-project-mode.sh  warka-forge
refused: warka-forge is registered with pr=batch and forge=forgejo in $LAB/data/projects.md; pr=batch ships a project with no forge binding only; drop the pr token
[exit 3]
$ FM_HOME=$LAB bin/fm-project-mode.sh --pr warka-forge
refused: warka-forge is registered with pr=batch and forge=forgejo in $LAB/data/projects.md; pr=batch ships a project with no forge binding only; drop the pr token
[exit 3]
$ FM_HOME=$LAB bin/fm-project-mode.sh --forge warka-forge
forgejo
[exit 0]
$ FM_HOME=$LAB bin/fm-project-mode.sh  warka-gerrit
refused: warka-gerrit is registered with pr=batch and forge=gerrit in $LAB/data/projects.md; pr=batch ships a project with no forge binding only; drop the pr token
[exit 3]
$ FM_HOME=$LAB bin/fm-project-mode.sh --pr warka-gerrit
refused: warka-gerrit is registered with pr=batch and forge=gerrit in $LAB/data/projects.md; pr=batch ships a project with no forge binding only; drop the pr token
[exit 3]
$ FM_HOME=$LAB bin/fm-project-mode.sh --forge warka-gerrit
gerrit
[exit 0]
$ FM_HOME=$LAB bin/fm-project-mode.sh  warka-bogus
refused: unknown PR binding "pr=batches" registered for warka-bogus in $LAB/data/projects.md; the accepted values are pr=manual and pr=batch, or no pr token at all for the pipeline's own PR text; correct the registry entry
[exit 3]
$ FM_HOME=$LAB bin/fm-project-mode.sh --pr warka-bogus
refused: unknown PR binding "pr=batches" registered for warka-bogus in $LAB/data/projects.md; the accepted values are pr=manual and pr=batch, or no pr token at all for the pipeline's own PR text; correct the registry entry
[exit 3]
$ FM_HOME=$LAB bin/fm-project-mode.sh --forge warka-bogus
none
[exit 0]
Evidence: fm-brief pr=batch scaffold and refusal transcript

Source: fm-brief pr=batch scaffold and refusal transcript

$ bin/fm-brief.sh wk-nm warka-nm --mode no-mistakes --pr batch
scaffolded: $LAB/data/wk-nm/brief.md (ship, mode=no-mistakes pr=batch; replace {TASK} and {FIRSTMATE_SPEC})
[exit 0]
$ bin/fm-brief.sh wk-dpr warka-direct --mode direct-PR --pr batch
scaffolded: $LAB/data/wk-dpr/brief.md (ship, mode=direct-PR pr=batch; replace {TASK} and {FIRSTMATE_SPEC})
[exit 0]
$ bin/fm-brief.sh wk-fix warka-nm --mode no-mistakes --pr batch --base-branch batch/keyse/3
scaffolded: $LAB/data/wk-fix/brief.md (ship, mode=no-mistakes pr=batch; replace {TASK} and {FIRSTMATE_SPEC})
[exit 0]
$ bin/fm-brief.sh wk-r1 warka-local --mode local-only --pr batch
error: fm-brief.sh --pr: pr=batch ships mode=no-mistakes or direct-PR only - local-only opens no pull request to batch
[exit 1]
$ bin/fm-brief.sh wk-r2 warka-forge --mode no-mistakes --forge forgejo --pr batch
error: fm-brief.sh --pr: pr=batch ships a project with no forge binding only, not forge=forgejo
[exit 1]
$ bin/fm-brief.sh wk-r3 warka-gerrit --mode direct-PR --forge gerrit --pr batch
error: fm-brief.sh --pr: pr=batch ships a project with no forge binding only, not forge=gerrit
[exit 1]
$ bin/fm-brief.sh wk-r4 warka-nm --scout --pr batch
error: --forge, --shape, and --pr apply only to ship briefs; a scout delivers a report and a secondmate charter is not a delivery contract
[exit 1]
$ bin/fm-brief.sh wk-r5 warka-nm --mode no-mistakes --pr batchy
error: fm-brief.sh --pr: unknown PR posture 'batchy' (expected auto, manual, or batch)
[exit 1]
Evidence: Generated no-mistakes pr=batch brief

Source: Generated no-mistakes pr=batch brief

You are a crewmate: an autonomous worker agent managed by firstmate. Work on your own; do not wait for a human.

# Task
## Captain's intent
{TASK}

## Firstmate spec
{FIRSTMATE_SPEC}

# Herdr lifecycle declaration - NOT ENABLED
**HARD SAFETY GATE:** this scaffold cannot inspect the task text filled in above.
If the task will start, stop, delete, restart, profile, or otherwise drive Herdr lifecycle behavior, stop and regenerate the brief with `--herdr-lab` before dispatch.
Do not add Herdr lifecycle commands to this unguarded brief by hand.

# Setup
You are in a disposable git worktree of warka-nm, at a detached HEAD on a clean default branch.

**Verify isolation before anything else.** Run `pwd -P` and `git rev-parse --show-toplevel`; both must resolve to the disposable task worktree you were launched in, such as a treehouse pool path or an Orca-managed worktree, not the primary checkout firstmate operates from.
The path check is authoritative: `git rev-parse --git-dir` and `git rev-parse --git-common-dir` can help inspect the repo, but they do not prove you are outside the primary checkout.
If the top-level path is the primary checkout or not the worktree you were launched in, STOP - do not branch or commit here - append `blocked [at=<epoch>]: launched in primary checkout, not an isolated worktree` to the status file and stop.

1. First action: create your branch: `git checkout -b fm/wk-nm --`
2. Run `no-mistakes doctor`; if it reports the repo is not initialized here, run `no-mistakes init`.

# Rules
1. Never push to the default branch. Never merge a PR. The one exception is `scripts/batch.sh ship`, which your Definition of done has you run: it pushes the project's batch branch, opens or extends the shared batch PR, and may arm its auto-merge under the project's own setting. Never push to a batch branch, or open, edit, merge, or close a batch PR, any other way.
2. Keep project edits inside this worktree; keep proof and scratch output outside it, under `/var/folders/zl/jngkp57j2fl0x5_p_m19jgfw0000gn/T//fm-lab.el2LTL/data/wk-nm/` or a temporary directory.
   Outside the worktree, write only that task material and the status and steering-inbox records authorized below.
   Leave the worktree clean before reporting done.
3. Use gh-axi for GitHub operations and chrome-devtools-axi for browser operations.
4. Report status by appending one line:
   `echo "{state} [at=<epoch>]: {one short line}" >> '/var/folders/zl/jngkp57j2fl0x5_p_m19jgfw0000gn/T//fm-lab.el2LTL/state/wk-nm.status' && { [ ! -e '/var/folders/zl/jngkp57j2fl0x5_p_m19jgfw0000gn/T//fm-lab.el2LTL/config/fleet-ledger' ] || '~/.no-mistakes/worktrees/073249faa5d1/01M800WM1V16135KR0C1ARZV0R/bin/fm-fleet-ledger.sh' appended '/var/folders/zl/jngkp57j2fl0x5_p_m19jgfw0000gn/T//fm-lab.el2LTL/config' '/var/folders/zl/jngkp57j2fl0x5_p_m19jgfw0000gn/T//fm-lab.el2LTL/state/wk-nm.status' >/dev/null 2>&1 || true; }`
   States: working, needs-decision, blocked, paused, done, failed.
   Substitute `<epoch>` with the current Unix time in seconds - run `date +%s` and write the number it printed; a stamp that is not plain digits records no time at all.
   Each append wakes firstmate, so report sparingly: only phase changes a supervisor
   would act on (setup done, bug reproduced, fix implemented, validation passed) and the
   needs-decision/blocked/paused/done/failed states. No step-by-step FYI progress lines;
   firstmate reads your pane for that.
   Whenever you mention a PR anywhere - a status line, your terminal, a summary - write its full
   https:// URL exactly as the forge printed it, never a bare number such as "PR 108"; firstmate
   copies that URL from your line rather than assembling one.
   A mid-task `working:` line (including setup complete) is nonterminal: do not end the
   turn after it; continue the same stage until a defined `done:` gate under Definition of done.
   Use `paused: {why}` - distinct from `blocked:` - when deliberately waiting for work or an external condition expected to clear on its own, including your own validation round.
   Before ending your turn with your own background shell or monitor still running, or before waiting on your own pipeline run or a long foreground command, append `paused [at=<epoch>]: {job and completion condition}` to the status file.
   Name what you are waiting for and what will let you resume; do not repeat the declaration on every poll.
   Do not declare active implementation or reasoning as a wait.
   Firstmate may still raise one first-sight alert; the declared wait then uses the existing long recheck cadence instead of repeated possible-wedge alarms.
   When you know when the wait clears, include `until <YYYY-MM-DDTHH:MMZ>` (UTC) for a recheck at that time; for your own background job or command with a timeout, that time is its start plus its timeout, rounded up to the minute.
   Follow the resolution rule below when the wait clears, then resume the task.
   Use `blocked:` when you are stuck and need help.

5. If you hit the same obstacle twice, append `blocked [at=<epoch>]: {why}` and stop; firstmate will help.
6. If a decision belongs above the implementation worker (product choices, destructive actions),
   append `needs-decision [at=<epoch>]: {summary of options}` and stop. Firstmate will reply with the decision.
   For a no-mistakes ask-user gate specifically, escalate all ask-user findings as one event plus one snapshot file, using that same shape even when the gate holds only a single ask-user finding: write only the ask-user findings, verbatim and unparaphrased (id, severity, file, line, description, authority), to `/var/folders/zl/jngkp57j2fl0x5_p_m19jgfw0000gn/T//fm-lab.el2LTL/data/wk-nm/nm-<run>-findings.txt`, then report the gate with
   `needs-decision [at=<epoch>] [key=nm-<run>-<step>]: ask-user findings=<id1>,<id2>,... file=/var/folders/zl/jngkp57j2fl0x5_p_m19jgfw0000gn/T//fm-lab.el2LTL/data/wk-nm/nm-<run>-findings.txt`
   naming every ask-user finding id from that gate. The status line only points at the file; it never restates or summarizes a finding's content.
   A decision or blocker you opened stays open until a `resolved` line carrying its exact key lands; a later `done:` or `working:` line never closes it, even when the answer is what started that work.
   Firstmate's reply normally writes that closing line at answer time; when a blocker or wait clears WITHOUT a firstmate reply, append `resolved [at=<epoch>]: {how it cleared}` yourself (same `[key=<slug>]` if you opened it with one) as you resume.
7. Never administer infrastructure that every lane shares. Two things are shared:
   - The `no-mistakes` daemon - one instance serving every lane/home, so stopping, restarting, or
     updating it kills other lanes' in-flight pipeline runs; only firstmate manages the daemon.
     Before you append `blocked:` about the pipeline, run `no-mistakes daemon status` and
     `no-mistakes axi status`. If the daemon socket refuses connections or is missing, append
     `blocked [at=<epoch>]: {the daemon error}` and stop even when the local run record still says running or
     fixing, because that record can be stale after the daemon exits. A run record failed with a
     daemon error is also a real block.
     Only after ruling out socket refusal, if the run is still running or fixing, reattach and keep
     going. A drive-call error, timeout, slow read, or generic unreachability is NOT a daemon error:
     the daemon accepts `respond` immediately and runs the round in the background, so a killed or
     timed-out call was only waiting for a read while the run kept working.
   - The worktree pool your own worktree came from, and the repository every lane's worktree
     shares. Never create, remove, return, prune, move, or reassign a worktree or pool slot, and
     never write into a sibling slot's directory. Rule 2 does not cover this: removing a worktree
     is administration rather than an edit outside your directory, and it lands on lanes that are
     running right now. The act is the rule and commands are only examples of it - `treehouse`
     get/return/remove/prune, the equivalent operations on any other

... [2600 bytes truncated] ...

of done
Delivery contract: mode=no-mistakes pr=batch
Ship branch: fm/wk-nm
This project batches its finished branches into one PR at a time with its own `scripts/batch.sh`, so **no-mistakes runs here as a validation pass that pushes the branch**, and the batch, not the pipeline, opens the PR.
Pass `--skip pr,ci` on every `no-mistakes axi run` for this task, and skip nothing else: `review`, `test`, `document`, `lint`, and `push` still run, and `ci` has no pipeline-opened PR to watch.
The task is complete only when committed on your branch.
When you believe it is complete, append `done [at=<epoch>]: {summary}` to the status file and stop.
Firstmate will then instruct you to run /no-mistakes to validate and push.
That first `done:` is the handoff that starts the pipeline, which owns the push; it is not a request to push from this copy.

You drive no-mistakes by responding to its gates, not by implementing fixes.
Follow the guidance no-mistakes itself provides for the mechanics: it loads when you invoke /no-mistakes, and `no-mistakes axi run --help` plus the `help` lines in each `axi` response are authoritative and version-matched to the installed binary.
When starting no-mistakes, pass `--intent` as only this brief's `## Captain's intent` subsection body, not its heading, plus any later words the captain actually said.
Preserve the actual words without adding speaker labels or direct address; the subsection heading supplies provenance outside the pipeline input.
For a legacy brief with no such subsection, include only words on lines marked `[captain] `, excluding that metadata prefix; never copy its mixed `# Task` wholesale.
If it has no provenance-marked captain words, stop and ask firstmate instead of starting no-mistakes.
Do not include `## Firstmate spec`, later Firstmate build constraints, or your own decisions and tradeoffs.
The `--intent` string you pass must be self-sufficient: that string plus the codebase must let a reader reconstruct roughly the same specification, without depending on a separate report, a PR, or context that lives only in this conversation.
When the captain's intent refers to a report, decision, or PR ("do items 1, 2, 3, and 7 of the report"), write the substance of the referenced items into `--intent` in the captain's terms, not only the pointer; that substance is the captain's ask by reference, while Firstmate's build instructions and your own decisions still stay out.
This replaces the no-mistakes skill's advice to enrich `--intent` with decisions and tradeoffs; that advice does not apply to Firstmate-dispatched work.
Do not hand-edit, commit, or fix findings yourself while a run is active - the pipeline applies every fix.

One drive call blocks until the next gate or outcome, which routinely outlives what your harness lets a single command run: Claude Code kills a command at ten minutes maximum, while one fix round is capped around thirty minutes and up to three rounds chain.
So background the drive call instead of sitting in one blocking hold your harness will kill, and read its return when it finishes.
Declare that wait using the brief's status-reporting rule before waiting on the backgrounded drive call.
Where a harness's own command limit is not established, assume it bounds commands and use that same backgrounded shape.
Whenever a drive call returns without a gate or an outcome - its own wait elapsed, or it was killed or timed out - reattach at once by re-running `no-mistakes axi run` without flags, backgrounded the same way; if it refuses because no run is active, read the finished outcome from `no-mistakes axi status`.
A killed or timed-out call is never evidence the daemon died: the daemon accepts your response immediately and runs the round in the background, so the call was only ever waiting for a read while the run kept working.
Reattach and keep going rather than reporting the pipeline blocked; rule 7 owns the checks that decide when a pipeline block is real.

Two firstmate-specific rules layer on top of that guidance:
- ask-user findings are never yours to answer: escalate to firstmate using rule 6's ask-user format and stop.
  Firstmate applies `ask-user-authority` and obtains any required captain decision.
  When the decision comes back, feed it to the gate with `no-mistakes axi respond` and let the pipeline apply it - do not route the question to "the user" or implement the fix yourself.
- NEVER pass `--yes` (or `-y`) to `no-mistakes axi run` or `no-mistakes axi respond`. It is banned fleet-wide.
  It auto-resolves every gate including ask-user findings with no escalation, and answering your own ask-user finding is a hard rule violation.

When the run's outcome is passed, passed-with-skips, or passed-with-override, its push step has put your validated branch on the forge.
Ship the pushed branch into a batch with the project's own `scripts/batch.sh`, run from this copy; its header explains the batching.
Until `scripts/batch.sh ship` takes `fm/wk-nm` into a batch it is still yours to fix. From that moment never rewrite it - no rebase, amend, reset, or force-push - because a batch merges each branch exactly as it was pushed.
1. Wait for the project's per-branch check on your pushed head: find its run, the newest one for your head commit in `gh run list --branch fm/wk-nm --limit 5`, and watch it with `gh run watch <id> --exit-status`, under the ten-minute command limit as the driving rules bound every wait, re-running the watch while it is still in progress.
   Then run `scripts/batch.sh status` and find `fm/wk-nm`. If it is still listed as waiting for that check, watch again.
   If it is listed as failed, read the failed run with `gh run view <id> --log-failed`, commit the fix on your branch, drive a new run with the same `--skip pr,ci`, which pushes it, and wait again.
2. Run `scripts/batch.sh ship`. It is idempotent: when it reports that another ship is running, run `scripts/batch.sh status` once more and then `ship` again.
   When it reports that `fm/wk-nm` conflicts with the batch, merge origin's default branch (`origin/<default>`) into your branch (`git fetch origin` first), resolve the conflict, drive a new run with the same `--skip pr,ci`, which pushes it, and go back to step 1.
3. Run `scripts/batch.sh status` again and find `fm/wk-nm`:
   - Under "in the open batch": the open batch PR carries your branch. Read its URL from `gh-axi pr view <number>`, with the number the status printed, and go to step 4.
   - Under "ready for the next batch": another batch is open and your branch waits for the next one, which is a normal outcome, not a failure. Append `paused [at=<epoch>]: queued for the next batch behind PR {open batch PR url}` and stop. When that PR merges or closes, firstmate tells you to resume, and you continue at step 2, which opens the next batch with your branch in it.
   - Under "fixes, joining the open batch at the next ship", or still waiting for the per-branch check: go back to step 1.
4. Wait for the batch PR's checks with `gh-axi pr checks <number> --watch`, under the ten-minute command limit as the driving rules bound every wait, and run the same command again whenever it returns with checks still pending. The project may merge a green batch on its own; a merged batch PR counts as green.
   - When its checks are green or it has merged, append `done [at=<epoch>]: PR {batch PR url} checks green` and stop. You are finished. Other tasks may report the same batch PR; firstmate tracks each against it, and they land together when it merges.
     That `done:` is accepted only when this copy's HEAD - your latest commit - is the pushed head of `fm/wk-nm`, so commit nothing after shipping.
   - When a check fails, do not fix it on your branch, which the batch already carries. Append `blocked [at=<epoch>]: batch PR {url} failed {check}: {one-line cause from its log}; needs a fix-forward branch cut from scripts/batch.sh base` and stop. Firstmate dispatches the fix as a separate task whose branch joins this batch, then tells you to resume at step 4.
   - When it closes without merging, go back to step 2.
Never run a `scripts/batch.sh` subcommand other than `status`, `ship`, and `base`.
Evidence: fm-spawn drift refusal / agreement transcript

Source: fm-spawn drift refusal / agreement transcript

## Registry
# Projects
- warka-prod [no-mistakes-prod-only pr=batch] - batching, conditional policy (added 2026-11-21)
- warka-nm [no-mistakes +yolo pr=batch] - batching (added 2026-11-21)

## Drift 1: warka-prod is registered pr=batch; a direct-PR brief scaffolded WITHOUT --pr batch
$ B sp-a warka-prod --mode direct-PR
scaffolded: $LAB/data/sp-a/brief.md (ship, mode=direct-PR; replace {TASK} and {FIRSTMATE_SPEC})
[exit 0]
$ S sp-a $LAB/projects/warka-prod sh -c 'sleep 60' --mode direct-PR --yolo off --backend tmux
fm-gate-refuse: gate agent lifecycle permitted only against lab home $LAB
error: PR-text mismatch for sp-a: warka-prod is registered pr=batch but $LAB/data/sp-a/brief.md records pr=auto; keep the filled ## Captain's intent and ## Firstmate spec bodies, remove $LAB/data/sp-a/brief.md, re-scaffold it with fm-brief.sh sp-a warka-prod --mode direct-PR --pr batch, then re-fill those two subsections, so the worker owns the PR text exactly when the project says so
[exit 1]
task recorded? no

## Drift 2: brief carries pr=batch, but the registry entry has no pr token
$ B sp-b warka-nm --mode no-mistakes --pr batch
scaffolded: $LAB/data/sp-b/brief.md (ship, mode=no-mistakes pr=batch; replace {TASK} and {FIRSTMATE_SPEC})
[exit 0]
- warka-nm [no-mistakes +yolo] - batching (added 2026-11-21)
$ S sp-b $LAB/projects/warka-nm sh -c 'sleep 60' --mode no-mistakes --yolo on --backend tmux
fm-gate-refuse: gate agent lifecycle permitted only against lab home $LAB
error: PR-text mismatch for sp-b: warka-nm is registered pr=auto but $LAB/data/sp-b/brief.md records pr=batch; keep the filled ## Captain's intent and ## Firstmate spec bodies, remove $LAB/data/sp-b/brief.md, re-scaffold it with fm-brief.sh sp-b warka-nm --mode no-mistakes, then re-fill those two subsections, so the worker owns the PR text exactly when the project says so
[exit 1]
task recorded? no

## Agree 1: warka-prod direct-PR brief WITH --pr batch
$ B sp-c warka-prod --mode direct-PR --pr batch
scaffolded: $LAB/data/sp-c/brief.md (ship, mode=direct-PR pr=batch; replace {TASK} and {FIRSTMATE_SPEC})
[exit 0]
$ S sp-c $LAB/projects/warka-prod sh -c 'sleep 60' --mode direct-PR --yolo off --backend tmux
fm-gate-refuse: gate agent lifecycle permitted only against lab home $LAB
~/.no-mistakes/worktrees/073249faa5d1/01M800WM1V16135KR0C1ARZV0R/bin/backends/tmux.sh: line 97: tmux: command not found
~/.no-mistakes/worktrees/073249faa5d1/01M800WM1V16135KR0C1ARZV0R/bin/backends/tmux.sh: line 119: tmux: command not found
~/.no-mistakes/worktrees/073249faa5d1/01M800WM1V16135KR0C1ARZV0R/bin/backends/tmux.sh: line 123: tmux: command not found
[exit 1]
--- state/sp-c.meta

## Agree 2: warka-nm no-mistakes brief WITH --pr batch, +yolo
$ B sp-d warka-nm --mode no-mistakes --pr batch
scaffolded: $LAB/data/sp-d/brief.md (ship, mode=no-mistakes pr=batch; replace {TASK} and {FIRSTMATE_SPEC})
[exit 0]
$ S sp-d $LAB/projects/warka-nm sh -c 'sleep 60' --mode no-mistakes --yolo on --backend tmux
fm-gate-refuse: gate agent lifecycle permitted only against lab home $LAB
~/.no-mistakes/worktrees/073249faa5d1/01M800WM1V16135KR0C1ARZV0R/bin/backends/tmux.sh: line 97: tmux: command not found
~/.no-mistakes/worktrees/073249faa5d1/01M800WM1V16135KR0C1ARZV0R/bin/backends/tmux.sh: line 119: tmux: command not found
~/.no-mistakes/worktrees/073249faa5d1/01M800WM1V16135KR0C1ARZV0R/bin/backends/tmux.sh: line 123: tmux: command not found
[exit 1]
--- state/sp-d.meta
Evidence: fm-promote transcript

Source: fm-promote transcript

$ FM_HOME=$LAB bin/fm-promote.sh pm-nm --mode no-mistakes --yolo off
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  watcher supervision needs Stop-owned automatic recovery; inspect the hook registration and startup status before ending the turn.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
promoted pm-nm to ship mode=no-mistakes yolo=off pr=batch (teardown protection restored)
wrote ship instructions for mode=no-mistakes pr=batch: $LAB/data/pm-nm/ship-instructions.md
next: FM_HOME=$LAB bin/fm-send.sh fm-pm-nm "$(cat $LAB/data/pm-nm/ship-instructions.md)"
[exit 0]
--- delivered contract line + rule 1:
1. Never push to the default branch. Never merge a PR. The one exception is `scripts/batch.sh ship`, which your Definition of done has you run: it pushes the project's batch branch, opens or extends the shared batch PR, and may arm its auto-merge under the project's own setting. Never push to a batch branch, or open, edit, merge, or close a batch PR, any other way.
Delivery contract: mode=no-mistakes pr=batch

$ FM_HOME=$LAB bin/fm-promote.sh pm-dpr --mode direct-PR --yolo off
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
promoted pm-dpr to ship mode=direct-PR yolo=off pr=batch (teardown protection restored)
wrote ship instructions for mode=direct-PR pr=batch: $LAB/data/pm-dpr/ship-instructions.md
next: FM_HOME=$LAB bin/fm-send.sh fm-pm-dpr "$(cat $LAB/data/pm-dpr/ship-instructions.md)"
[exit 0]
--- delivered contract line + rule 1:
1. Never push to the default branch (push only your `fm/pm-dpr` branch). Never merge a PR. The one exception is `scripts/batch.sh ship`, which your Definition of done has you run: it pushes the project's batch branch, opens or extends the shared batch PR, and may arm its auto-merge under the project's own setting. Never push to a batch branch, or open, edit, merge, or close a batch PR, any other way.
Delivery contract: mode=direct-PR pr=batch

$ FM_HOME=$LAB bin/fm-promote.sh pm-lo --mode local-only --yolo off
WARNING: watcher still down (same stale episode; last beat: never, grace 300s) - full banner already printed this episode.
promoted pm-lo to ship mode=local-only yolo=off (teardown protection restored)
wrote ship instructions for mode=local-only: $LAB/data/pm-lo/ship-instructions.md
next: FM_HOME=$LAB bin/fm-send.sh fm-pm-lo "$(cat $LAB/data/pm-lo/ship-instructions.md)"
[exit 0]
--- delivered contract line + rule 1:
1. Never push to any remote and never open a PR. Work only on your `fm/pm-lo` branch; firstmate handles the merge into local `main`.
Delivery contract: mode=local-only

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 warnings
  • ⚠️ .agents/skills/project-management/SKILL.md:64 - Part of the intent is missing. The intent says: 'Docs (docs/configuration.md PR posture selection, project-management skill, README) note batch.automerge should only be set on +yolo projects.' Only docs/configuration.md:2407 has that note, and even there it says 'whether a batch pull request is armed for auto-merge' without naming the batch.automerge setting. The new pr=batch line in the project-management skill (.agents/skills/project-management/SKILL.md:64) and the README bullet (README.md:48) say nothing about auto-merge or +yolo. Firstmate could register a non-yolo project with pr=batch, and the project's own auto-merge would then merge batch PRs with no merge authority. Fix: add a one-sentence note in both places, and name batch.automerge in docs/configuration.md.
  • ⚠️ .agents/skills/ship-landing/SKILL.md:24 - Firstmate's yolo merge would squash a batch PR, but the intent assumes batches merge with --no-ff. The intent says 'yolo merge and teardown all work unchanged ... because batches merge with --no-ff'. On GitHub, bin/fm-pr-merge.sh uses --squash unless the caller names a method (bin/fm-pr-merge.sh:22, :1889-1890). The new ship-landing text only says 'merge it once' and gives no method. Failure case: on a +yolo pr=batch project, task A reports 'done: PR <batch> checks green' and firstmate merges with no method. The batch lands on main as one squash commit, so none of the batched fm/* branches are ancestors of main. Teardown still passes, because pr_is_merged compares against the PR head, not main. But anything in Warka's scripts/batch.sh that decides whether a branch is merged or ready by ancestry on main can see those branches as unmerged and re-batch them on the next ship. The project's own --no-ff history is also lost. Fix: tell firstmate to merge batch PRs with bin/fm-pr-merge.sh &lt;id&gt; &lt;url&gt; -- --merge, or have the merge path pick --merge for pr=batch tasks. Picking the merge method is a product decision, so asking the user.
  • ⚠️ bin/fm-dod-lib.sh:229 - For a batched task, bin/fm-review-diff.sh shows the whole batch's diff as that task's change, with no error. The batched worker reports the shared batch PR, so the task's recorded pr= is that PR. fm-review-diff.sh (lines 167-172) always compares against the fetched refs/pull/<n>/head when pr= is set. Failure case: tasks A and B both sit in batch PR fix: keep idle watcher supervision silent kunchenguid/firstmate#10, and fm-review-diff.sh A shows B's changes and the batch merge commits as A's work. A fix-forward task shows the entire batch. Any review or captain report built from that diff for a pr=batch task covers the wrong content. Fix: compare against the task's own ship branch when the task is batched. Nothing in the task metadata records pr=batch today, so the fix needs a new metadata field or a registry lookup. That remedy is new state, so asking the user.
  • ℹ️ tests/fm-task-delivery.test.sh:1577 - The new pr=batch tests were inserted between an existing comment block and the test it describes. That comment ('green checks on a server that has neither ... local-only, which publishes nothing, cannot carry it') belongs to test_spawn_requires_the_brief_to_carry_the_registered_forge. It now sits directly above the pr=batch comment and test_pr_batch_brief_ships_through_the_project_batch, so it describes the wrong test. Fix: move the three new tests above that comment block.

🔧 Fix applied.
2 warnings still open:

  • ⚠️ .agents/skills/ship-landing/SKILL.md:24 - Firstmate's yolo merge would squash a batch PR, but the intent assumes batches merge with --no-ff. The intent says 'yolo merge and teardown all work unchanged ... because batches merge with --no-ff'. On GitHub, bin/fm-pr-merge.sh uses --squash unless the caller names a method (bin/fm-pr-merge.sh:22, :1889-1890). The new ship-landing text only says 'merge it once' and gives no method. Failure case: on a +yolo pr=batch project, task A reports 'done: PR <batch> checks green' and firstmate merges with no method. The batch lands on main as one squash commit, so none of the batched fm/* branches are ancestors of main. Teardown still passes, because pr_is_merged compares against the PR head, not main. But anything in Warka's scripts/batch.sh that decides whether a branch is merged or ready by ancestry on main can see those branches as unmerged and re-batch them on the next ship. The project's own --no-ff history is also lost. Fix: tell firstmate to merge batch PRs with bin/fm-pr-merge.sh &lt;id&gt; &lt;url&gt; -- --merge, or have the merge path pick --merge for pr=batch tasks. Picking the merge method is a product decision, so asking the user.
  • ⚠️ bin/fm-dod-lib.sh:229 - For a batched task, bin/fm-review-diff.sh shows the whole batch's diff as that task's change, with no error. The batched worker reports the shared batch PR, so the task's recorded pr= is that PR. fm-review-diff.sh (lines 167-172) always compares against the fetched refs/pull/<n>/head when pr= is set. Failure case: tasks A and B both sit in batch PR fix: keep idle watcher supervision silent kunchenguid/firstmate#10, and fm-review-diff.sh A shows B's changes and the batch merge commits as A's work. A fix-forward task shows the entire batch. Any review or captain report built from that diff for a pr=batch task covers the wrong content. Fix: compare against the task's own ship branch when the task is batched. Nothing in the task metadata records pr=batch today, so the fix needs a new metadata field or a registry lookup. That remedy is new state, so asking the user.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 8 of 10 scenarios driven live against the product
Scenario Result Live Evidence
Captain registers pr=batch on no-mistakes, no-mistakes-prod-only and direct-PR projects and fm-project-mode --pr reports 'batch' with the two-word posture unchanged ✅ pass live 01-project-mode-transcript.txt
Adversarial: pr=batch on local-only, beside forge=forgejo or forge=gerrit, or an unknown pr=batches value is refused (exit 3, empty stdout, reason named) while --forge still answers ✅ pass live 01-project-mode-transcript.txt
fm-brief --pr batch on no-mistakes renders 'Delivery contract: mode=no-mistakes pr=batch', --skip pr,ci only, the rule-1 scripts/batch.sh ship carve-out, and the done/paused/blocked lines ✅ pass live 02-brief-scaffold-transcript.txt, 03-brief-wk-nm.md
fm-brief --pr batch on direct-PR pushes fm/* and opens no PR, then follows the same batch steps and carve-out ✅ pass live 03-brief-wk-dpr.md
Fix-forward brief with --base-branch set to the batch branch rebases onto it and merges origin/<batch> to resolve conflicts ✅ pass live 03-brief-wk-fix.md
Adversarial: fm-brief refuses --pr batch on local-only, with --forge forgejo or gerrit, on --scout, and an unknown --pr value, writing no brief ✅ pass live 02-brief-scaffold-transcript.txt
Adversarial: fm-spawn refuses drift both ways (registry pr=batch vs brief without it on a prod-only project's direct-PR task; brief pr=batch vs registry without it), records no task, and prints the ri… ✅ pass live 04-spawn-transcript.txt
fm-spawn accepts an agreeing pr=batch brief for direct-PR and no-mistakes+yolo and launches the worker ⏸️ untested no Live, both agreeing spawns passed the pr= binding check, then failed creating the endpoint because tmux is not on PATH. The Herdr lab (bin/fm-herdr-lab.sh prepare) refused: 'fleet-state tripwire requi…
fm-promote of a scout on a pr=batch project delivers pr=batch plus the rule-1 carve-out for no-mistakes and direct-PR, and drops it for local-only ✅ pass live 05-promote-transcript.txt and 05-promote-*-payload.md
End-to-end batch flow: worker runs scripts/batch.sh ship, reports 'done: PR <batch> checks green', several tasks share one batch PR through pr-check, the merge poll and teardown ⏸️ untested no This needs a GitHub repository with Warka's scripts/batch.sh, its branch-check workflow, a gh login that can open PRs, and a running worker agent. Making a GitHub repo or PR is an outward-facing actio…
  • bin/fm-lab-home.sh create $LAB disposable lab home with a fixture data/projects.md (7 pr=batch entries: valid, local-only, forgejo, gerrit, unknown value)
  • FM_HOME=$LAB bin/fm-project-mode.sh [--pr|--forge] &lt;warka-*&gt; for every entry, recording each exit status
  • FM_HOME=$LAB bin/fm-brief.sh &lt;id&gt; &lt;proj&gt; --mode no-mistakes|direct-PR --pr batch [--base-branch batch/keyse/3], then refusals for local-only, --forge forgejo, --forge gerrit, --scout, and --pr batchy
  • FM_HOME=$LAB bin/fm-spawn.sh in a marked lab home with git fixture projects with file:// origins: drift both ways (registry pr=batch vs brief auto; brief pr=batch vs registry auto), then agreeing direct-PR and no-mistakes+yolo briefs
  • FM_HOME=$LAB bin/fm-promote.sh &lt;scout-id&gt; --mode no-mistakes|direct-PR|local-only --yolo off on a no-mistakes-prod-only pr=batch project, capturing the delivered ship-instructions payload
  • bash tests/fm-project-mode.test.sh
  • bash tests/fm-task-delivery.test.sh (covers the new pr=batch brief, refusal and spawn tests)
  • Checked that the batch.automerge +yolo note appears in README.md, the project-management skill and docs/configuration.md, and that the diff has no em dash
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

A project that batches its finished branches into one pull request at a
time with its own scripts/batch.sh is registered with pr=batch. Workers on
no-mistakes skip the pipeline's pr and ci steps so it only validates and
pushes, direct-PR workers push without opening a PR, and both then run
scripts/batch.sh ship and report the shared batch PR once it is green or
merged. Several tasks record the same pr= and land when it merges.

A queued branch declares a wait, a failing batch is reported as a blocker
and fixed forward by a separate task cut from the batch with
--base-branch, and a batched branch is never rewritten. The ship-landing
skill says how firstmate resumes those workers.
@keyse
keyse merged commit e11d028 into main Nov 22, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant